/**
 * 
 */
package edu.cmu.cs.webapp.ioms.ui.providers.order;

import org.eclipse.jface.viewers.ITableLabelProvider;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.swt.graphics.Image;

import edu.cmu.cs.webapp.ioms.models.Client;
import edu.cmu.cs.webapp.ioms.utils.IOMSImageHelper;
import edu.cmu.cs.webapp.ioms.utils.IOMSImages;

/**
 * @author Christian
 * 
 */
public class CustomersTableViewerLabelProvider extends LabelProvider implements
		ITableLabelProvider {
	// table column index
	public static final int ClIENT_ID = 0;
	public static final int FNAME = 1;
	public static final int LNAME = 2;
	public static final int EMAIL = 3;
	public static final int PHONE = 4;
	public static final int COMPANY = 5;
	public static final int ADDRESS = 6;
	public static final int CITY = 7;
	public static final int STATE = 8;
	public static final int COUNTRY = 9;

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * org.eclipse.jface.viewers.ITableLabelProvider#getColumnImage(java.lang
	 * .Object, int)
	 */
	@Override
	public Image getColumnImage(Object element, int columnIndex) {
		if (element instanceof Client) {
			if (columnIndex == ClIENT_ID) {
				return IOMSImageHelper.getInstance().getImage(
						IOMSImages.IMG_CLIENT);
			}
		}

		return null;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * org.eclipse.jface.viewers.ITableLabelProvider#getColumnText(java.lang
	 * .Object, int)
	 */
	@Override
	public String getColumnText(Object element, int columnIndex) {
		if (element instanceof Client) {
			Client client = (Client) element;
			switch (columnIndex) {
			case ClIENT_ID:
				return "#" + client.getClient_id();
			case FNAME:
				return client.getFname();
			case LNAME:
				return client.getLname();
			case EMAIL:
				return client.getEmail();
			case PHONE:
				return client.getPhone();
			case COMPANY:
				return client.getCompany();
			case ADDRESS:
				return client.getAddress();
			case CITY:
				return client.getCity();
			case STATE:
				return client.getState();
			case COUNTRY:
				return client.getCountry();
			default:
				return "";
			}
		}

		return "";

	}
}
